/*
 * @Author: Islands 1430536748@qq.com
 * @Date: 2024-07-15 21:05:04
 * @LastEditors: 周洋 1430536748@qq.com
 * @LastEditTime: 2024-08-23 09:28:26
 * @version: 1.2.0
 * @Description: 
 */
import { PropType } from "vue";
import { PlacementEnum, ButtonTypeEnum } from '@/enum/index';
import { Plus, Close, Upload } from '@element-plus/icons-vue';
const IDirection = ['rtl', 'ltr','ttb','btt'] as const;
type IDirectionType = (typeof IDirection)[number];

//普通按钮
export const props = {
    /** Tooltip 组件出现的位置 */
    placement: { type: String as PropType<PlacementEnum>, default: PlacementEnum.TOP},
    /** 按钮类型 */
    type: { type: String as PropType<ButtonTypeEnum>, default: ButtonTypeEnum.PRIMARY},
    /** 图标 */
    icon: { type: [String, Object], default: ''},
    /** 是否为链接按钮 */
    link: { type: Boolean, default: false},
    /** 按钮文本 */
    text: { type: String, default: null },
    /** 大小 */
    size: { type: [String, Number], default: '1em' },
    /** 显示内容(tooltip有效) */
    content: { type: String, default: ''},
    /** popover窗口宽度（popover有效） */
    popoverWidth: { type: [String, Number], default: 150 },
    /** 列表参数（popover有效）*/
    options: { type: Array<any>, default: [] },
    /** 按钮点击事件 */
    onClick: { type: Function as PropType<((command: any) => any) | (() => any)>},
};

/** 弹窗按钮 */
export const modeProps = {
    /** 弹窗标题 */
    title: { type: String, required: true },
    /** 弹窗宽度 */
    width: {type: [String || Number], default: 520, },
    /** 自定义弹窗类名 */
    customClass: { type: String, default: 'customClass'},
    /** 按钮文字 */
    btnText: {type: String, default: '打开'},
    /** 按钮类型 */
    btnType: {type: String as PropType<ButtonTypeEnum>, default: ButtonTypeEnum.PRIMARY },
    /** 按钮图标 */
    btnIcon: { type: [String, Object], default: Plus},
    /** 是否为链接按钮 */
    btnLink: {type: Boolean, default: false },
    /** 提交按钮文字 */
    okText: { type: String, default: '确认' },
    /** 提交按钮类型 */
    okType: { type: String as PropType<ButtonTypeEnum>, default: ButtonTypeEnum.PRIMARY},
    /** 提交按钮图标 */
    okIcon: {type: [String, Object], default: Upload},
    /** 取消按钮文字 */
    cancelText: { type: String, default: '取消'},
    /** 取消按钮类型 */
    cancelType: { type: String as PropType<ButtonTypeEnum>, default: ButtonTypeEnum.INFO},
    /** 取消按钮图标 */
    cancelIcon: { type: [String, Object], default: Close },
    /** direction 当弹窗为drawer有效 */
    direction: { type: String as PropType<IDirectionType>, validator: (v: any) => IDirection.includes(v), default: 'rtl' },
}
//按钮组
export const renderProps = {
    /** 组按钮循环渲染函数 */
    GroupItems: { type: Array<Function>, required: true }
}
export interface Emits {
    /** 打开弹窗回调	 */
    (e: 'onOpen'): () => void;
    /** 点击遮罩层或右上角叉或取消按钮的回调	 */
    (e: 'onCancel'): () => void;
    /** 点击确定回调 */
    (e: 'onOk', close: () => void): () => void;
}